package com.runjian.rundo.iot.agent.iec104.action.impl;

import com.runjian.rundo.iot.agent.common.message.DeviceMessage;
import org.springframework.stereotype.Component;

import com.runjian.rundo.iot.agent.iec104.action.AbstractActionHandle;
import com.runjian.rundo.iot.agent.iec104.cache.ScheduleTaskCache;
import com.runjian.rundo.iot.agent.iec104.consts.Action;
import com.runjian.rundo.iot.agent.iec104.session.Iec104TcpClientDeviceSession;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 总召唤动作实现
 *
 * @author CaoQingHua
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class CancelAllTaskActionHandle extends AbstractActionHandle {

    private final ScheduleTaskCache scheduleTaskCache;

    @Override
    public Action getAction() {
        return Action.CANCEL_ALL_TASK;
    }

    @Override
    public void handle(DeviceMessage deviceMessage, Iec104TcpClientDeviceSession iec104DeviceSession) {
        // 一般此时管道停止工作了
        scheduleTaskCache.cancelFuture(iec104DeviceSession.getChannel());
    }
}
